<template>
    <div class="box-body">
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">在职进修学历(学位)教育信息</h3>
            </div>
            <div class="box-body">
                <el-form :model="editeducation" status-icon ref="editeducation" label-width="160px">
                    <div class="col-sm-6">
                        <el-form-item label="学历种类">
                            <el-select :disabled="!isEditable" v-model="editeducation.category" @change="value=>editeducation.category = value">
                                <el-option v-for="item in this.educategorylist" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div class="col-sm-6">
                        <el-form-item label="学历（学位）层次">
                            <el-select :disabled="!isEditable" v-model="editeducation.degree" @change="value=>editeducation.degree = value">
                                <el-option v-for="item in this.degrees" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div class="col-sm-6">
                        <el-form-item label="录取院校">
                            <el-input :disabled="!isEditable" v-model="editeducation.school" placeholder="请输入录取院校" auto-complete="off"></el-input>
                        </el-form-item>
                    </div>
                    <div class="col-sm-6">
                        <el-form-item label="进修专业">
                            <el-input :disabled="!isEditable" v-model="editeducation.discipline" placeholder="请输入进修专业" auto-complete="off"></el-input>
                        </el-form-item>
                    </div>
                    <div class="col-sm-6">
                        <el-form-item label="学制（年）">
                            <el-input :disabled="!isEditable" v-model="editeducation.years" placeholder="请输入学制（年）" auto-complete="off"></el-input>
                        </el-form-item>
                    </div>
                    <div class="col-sm-6">
                        <el-form-item label="毕业证书号码">
                            <el-input :disabled="!isEditable"  v-model="editeducation.graduationNo" placeholder="请输入毕业证书号码" auto-complete="off"></el-input>
                        </el-form-item>
                    </div>
                    <div class="col-sm-6">
                        <el-form-item label="学位证书号码">
                            <el-input :disabled="!isEditable" v-model="editeducation.degreeNo" placeholder="请输入学位证书号码" auto-complete="off"></el-input>
                        </el-form-item>
                    </div>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "FurtherEduForm",
        props: ["furtherEdu", "editable"],
        data(router) {
            return {
                isEditable: false,
                educategorylist: [],
                degrees: [],
                editeducation: {
                    category: 1,
                    degree: 1,
                    school: '',
                    discipline: '',
                    years: 1,
                    graduationNo: '',
                    degreeNo: ''
                }
            };
        },
        created: function() {
            if (this.furtherEdu) {
                this.editeducation = this.furtherEdu;
            }
            if (this.editable != null && this.editable != undefined) {
                this.isEditable = this.editable;
            }
            this.educategorylist = this.$store.state.sysconfigs.educategorylist
            this.degrees = this.$store.state.sysconfigs.FtEducation
        },
        methods: {
            getData: function() {
                var validRes = true;
                this.$refs.editeducation.validate(valid => {
                    if (valid) {
                        validRes = true;
                    } else {
                        console.log("error submit!!");
                        validRes = false;
                        return false;
                    }
                });
                console.log(" editEdu:", JSON.stringify(this.editEdu));
                if (!validRes) {
                    return null;
                }
                return this.editeducation;
            }
        }
    };
</script>

